package com.txh.blog.controller;

import com.txh.blog.model.Resme;
import com.txh.blog.service.ArticleService;
import com.txh.blog.service.ResMeservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.jws.WebParam;
import java.util.HashMap;
import java.util.Map;

@Controller
public class IndexController {

    @Autowired
    private ArticleService articleService;
    @Autowired
    private ResMeservice resMeservice;

    @RequestMapping("")
    public String index(@RequestParam Map<String,Object> param, Model model){
        Map<String,Object> page = articleService.articlePages(param,1);
        model.addAttribute("page",page);
        return "index";
    }

    @RequestMapping("/articleInfo/{id}")
    public String articleInfo(@PathVariable("id") Long id, Model model){
        Map<String,Object> result = articleService.getArticleInfoById(id);
        model.addAttribute("info",result);
        return "info";
    }

    @RequestMapping("/about")
    public String adout(Model model){
        Resme resme = resMeservice.getMeInfo();
        model.addAttribute("about",resme);
        return "about";
    }
}
